#! /bin/bash

OUT=phie

mkdir -p $OUT

echo $#;
if [ $# -eq 0 ]; then
	PHIE=`find . -name ph.igb.gz`;
else
	PHIE=$@
fi

for i in $PHIE; do
	echo "---------------------"
	BNAME=`basename $i`;
	DNAME=`dirname $i`;
	DNAME=${DNAME#./} # cut off ./
	
	meshname=`grep meshname $DNAME/parameters.par`
	meshname=${meshname#*=} # cut off *=
	meshname=${meshname%#*} # cut off comments
	meshname=${meshname//[[:space:]]}
 # strip whitespaces
	
	#echo $i
	echo "'$meshname'"
	#echo $BNAME
	#echo $DNAME

	cmd="time_series -o $OUT/$DNAME -d $i -v \
-p [-74127.000000 -60181.792969 -6644.637207] \
-2 [91194.445312 -57364.367188 -6644.637207] \
-i $meshname.pts \
-T $DNAME";
	echo " $ $cmd";
	eval $cmd;
	rm -f time_series.ini;
done


# -p [99630.875,70319.008 -6644.64] \
# -2 [-95475.140, -66650.547, -6644.64] \
